# include <bits/stdc++.h># define MAXN 50023using namespace std;inline int gn() {    int k = 0, f = 1;    char c = getchar();    for(; !isdigit(c); c = getchar()) if(c == '-') f = -1;    for(; isdigit(c); c = getchar()) k = 10 * k + c - '0';    return k * f;}bool win[MAXN];pair <int, int> fst[MAXN], sec[MAXN];int main() {    freopen("elect.in", "r", stdin);    freopen("elect.out", "w", stdout);    int n = gn(), k = gn();    for (int i = 1; i <= n; i++) {        fst[i] = make_pair(gn(), i);        sec[i] = make_pair(gn(), i);    }    sort(fst + 1, fst + n + 1);    sort(sec + 1, sec + n + 1);    for(int i = n, j = 1; j <= k; j++, i--) {        win[fst[i].second] = 1;    }    for(int i = n; i >= 1; i--) {        if(win[sec[i].second]) {            printf("%d\n", sec[i].second);            break;        }    }}